{% extends 'app01/base_backend.html' %}
  {% block person_manage %}
             <a class="navbar-brand" href="#">笔记收藏</a>
            {% endblock %}
{% block all_li %}
    <li role="presentation">
        <a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">笔记收藏</a>
    </li>
    <li role="presentation" class="active">
        <a href="{% url 'app01_backend' %}" style="color: #337ab7">返回个人管理</a></li>
{% endblock %}

{% block all_content %}
    {% block caogao %}
        <hr>
        {% for file in col_file %}
            <div class="media">
            <h4 class="media-heading"><a href="/app01/preview_file/?file_id={{ file.file_id }}&url={{ request.get_full_path_info }}"> {{ file.file.name }}</a></h4>
                <div class="media-left">
                    <a href="#">
                        <img class="media-object" src="/media/{{ file.file.userinfo.avatar }}/" height="64" alt="...">
                    </a>
                </div>
                <div class="media-body">
                     {{ file.file.desc }}
                </div>
            </div>
        <div class="pull-right">
            发布时间：{{ file.file.create_time }}&nbsp;&nbsp;&nbsp;
            <a href="/app01/site/{{ file.file.userinfo.username }}/"> 作者:{{ file.file.userinfo.username }}</a>&nbsp;&nbsp;&nbsp;
            <a href="#" style="color: indianred" class="del_file_class" file_id="{{ file.file_id }}">移除收藏</a>
        </div>

            <hr>
            {% empty %}
            <h3>您还没有收藏过笔记。。 </h3>


        {% endfor %}


        {# 分页显示 #}
        <div class="pager">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    {{ article_page_html }}
                </ul>
            </nav>
        </div>
    {% endblock %}

{% endblock %}
{% block js %}
    <script>
    //移除收藏
     $('.del_file_class').click(function () {
            //拿到自定义属性的属性值
            let file_id = $(this).attr('file_id')
            let op=confirm('是否取消收藏')
            if(op){
                 $.ajax({
                url:'',
                type:'post',
                data:{'file_id':file_id},
                success:function (attr) {
                    if(attr.code===100){
                        alert('移除收藏成功')
                        window.location.reload()
                    }
                    else {
                        alert(attr.msg)
                    }

                }
            })
            }


        })


        if('{{ request.user.username }}'.slice(0,3)==='512'){
         $('#p_for_a').html('<a href="/app01/manage_student/" class="list-group-item">学生管理</a>')
        $('#role_for').html('角色：<br><a href="#">老师</a>')
    }



    if('{{ request.user.username }}'.slice(0,3)==='312'){

        $('#set_person_id').html('<p>班级：<input type="text" id="stu_class" class="form-control" value="{{ request.user.stu_class }}"></p>')
         $('#role_for').html('角色：<br><a href="#">学生</a>')
        $('#MyClass').html("<a href='/app01/myclass/'> 我的班级 </a>")
    }

    </script>
{% endblock %}